<?php
include_once('server/config.php');
include_once('server/cmdVarControl.php');
include_once('server/htmlPreProc.php');
$cssPath = './css/';
$pageCSS = (get('page') == 'null' ? 'home' : get('page'));
if(check404(explode("\n", NAVIGATOR)) != 'yes' && get('page') != 'null')
{
	$pageCSS = '404';
}

$files = array('reset', '960', 'text', 'global', 'typography', 'workinprogress', 'slimbox', $pageCSS);

foreach ($files as $key => $file) {  
    $files[$key] = str_replace(array('/', '\\', '.'), '', $file);  
}  

$cssData = '';  
foreach ($files as $file) {  
    $cssFileName = $cssPath . $file . '.css';
    if(file_exists($cssFileName))
    {
    	if(filesize($cssFileName) > 0)
    	{
	    	$fileHandle = fopen($cssFileName, 'r');
	    	if(HTACCESS)
	    	{
	    		$cssData .= "\n" . str_replace('background-image: url(\'', 'background-image: url(\''.BASEURL, fread($fileHandle, filesize($cssFileName)));
	    	}
	    	else
	    	{
	    		$cssData .= "\n" . str_replace('background-image: url(\'', 'background-image: url(\'./', fread($fileHandle, filesize($cssFileName)));
	    	}
		      
		    fclose($fileHandle);  
    	}
    }
   }

header("Content-type: text/css");  
if (isset($cssData) && get('page') != 'null') {  
	$cssData = preg_replace('/\s+/', ' ', $cssData);
    echo $cssData;  
    echo "\n\n// Generated: " . date("r");  
} else {  
    echo "// Files not avalable or no files specified.";  
}  

?>